import Cookies from "js-cookie"
import router from './../router'
export default {
    resteUserId(state) {  // 退出登录，充值
        state.userId = "";
        state.userInfo = "";
        Cookies.remove('userId')
        router.push({ path: '/login'});
    },
    save(state,{path,data}){
        if (!path ) return false
        data = data ? data : ''
        state[path] = data
        if(path === "accountType"){
            Cookies.set('accountType',data,{ expires: 7});
        }
    },            //vuex.commit('save', {path:'maybe', data:"maybe"})
    updateUserId(state,value) {
        state.userId = value;
        Cookies.set('userId',value,{ expires: 7});
    }, 
    updateUserInfo(state,value) {
        state.userInfo = value;
        state.token = value.pushToken
        value = JSON.stringify(value);
        Cookies.set('userInfo',value,{ expires: 7 });
        // Cookies.set('userId',value,{ expires: 7 });
    },
    updateSubTitle(state,value) {
        state.subTitle = value;
    },
    setExchangeType(state,value){
        state.exchangeType = value;
    },
    setOrderCoinList(state,value){
        state.orderCoinList = value;
        console.log(state.orderCoinList);
    },
    addBankLsit(state,value){
        state.bankArr = value;
    }
}